/**
 * Copyright (C) 2013-2014 EaseMob Technologies. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.hengtiansoft.lfy.chart.activity;

import android.content.Intent;
import android.os.Bundle;

import com.hengtiansoft.lfy.R;
import com.hengtiansoft.lfy.widget.AlertDialog;
import com.hengtiansoft.lfy.chart.domain.FriendsUser;

public class ForwardMessageActivity extends PickContactNoCheckboxActivity {
    private FriendsUser selectUser;
    private String forward_msg_id;
    private String forward_msg_content;
    private String translate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        forward_msg_id = getIntent().getStringExtra("forward_msg_id");
        forward_msg_content = getIntent().getStringExtra("forward_msg_content");
        translate = getIntent().getStringExtra("translate");
    }

    @Override
    protected void onListItemClick(int position) {
        // if (position != 0) {
        selectUser = contactAdapter.getItem(position);
        Intent intent = new Intent(ForwardMessageActivity.this,
                AlertDialog.class);
        intent.putExtra("cancel", true);
        intent.putExtra("titleIsCancel", true);
        intent.putExtra(
                "msg",
                getString(R.string.confirm_forward_to, selectUser.getUsername()));
        startActivityForResult(intent, 1);
        // }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (resultCode == RESULT_OK) {
            try {
                ChatActivity.activityInstance.finish();
            } catch (Exception e) {
            }
            Intent intent = new Intent(this, ChatActivity.class);
            if (selectUser == null)
                return;
            // it is single chat
            intent.putExtra("userId", selectUser.getUsername());
            intent.putExtra("forward_msg_id", forward_msg_id);
            intent.putExtra("forward_msg_content", forward_msg_content);
            intent.putExtra("translate", translate);
            startActivity(intent);
            finish();

        }

        super.onActivityResult(requestCode, resultCode, data);
    }
}
